package com.share.convert;

import com.share.pojo.Dog;

import java.beans.PropertyEditorSupport;

/*
    自定义类型转换器
 */
public class MyPropertyEditor extends PropertyEditorSupport {

    @Override
    public void setAsText(String text) throws IllegalArgumentException {

        Dog dog = new Dog();
        String[] arr = text.split(",");
        dog.setName(arr[0]);
        dog.setColor(arr[1]);
//        setValue(dog);
//        this.setValue(dog);
        super.setValue(dog);
    }

    public static void main(String args[]) {
        MyPropertyEditor editor = new MyPropertyEditor();
        editor.setAsText("sunxj,black");
        System.out.println(editor.getValue());
    }
}
